function [t,psi,tht]=mat2tr(t,psi,tht);

%*** T IS THE TRANSFORMATION MATRIX OBTAINED FROM TWO
%*** ANGLE TRANSFORMATIONS PSI AND THT




t_orig=t;t_shape=[3,3];t=reshape([t_orig(1:min(prod(t_shape),numel(t_orig))),zeros(1,max(0,prod(t_shape)-numel(t_orig)))],t_shape);


t(1,3)=-sin(tht);
t(2,1)=-sin(psi);
t(2,2)=cos(psi);
t(3,3)=cos(tht);
t(1,1)=t(3,3).*t(2,2);
t(1,2)=-t(3,3).*t(2,1);
t(3,1)=-t(1,3).*t(2,2);
t(3,2)=t(1,3).*t(2,1);
t(2,3)=0.;

t_orig(1:min(prod(t_shape),numel(t_orig)))=t(1:min(prod(t_shape),numel(t_orig)));t=t_orig;
return;

end

